package com.kevin.pay.mapper;

import com.kevin.pay.domain.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface UserMapper {

    @Select("select * from user where id=#{id}")
    User findById(@Param("id") int userId);

    /**
     * 根据openId查找
     */
    @Select("select * from user where openid=#{openid}")
    User findByopenid(@Param("openid") String openid);

    @Insert("insert into user ( `openid`, `name`, `head_img`, `phone`, `sign`, `sex`, `city`, `create_time`) " +
            "values (#{openid},#{name},#{headImg},#{phone},#{sign},#{sex},#{city},#{createTime})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    int save(User user);
}
